<template>
  <el-dialog
    title="回收数据"
    :visible.sync="recoverDataShow"
    :destroy-on-close="true"
    :append-to-body="true"
    width="45%"
    @close="handleClose"
    class="edit-main"
  >
    <el-form
      ref="formData"
      :model="formData"
      :rules="rules"
      label-width="120px"
    >
      <el-form-item label="未接电话" prop="notAnswer">
        <el-checkbox-group v-model="formData.notAnswer">
          <el-checkbox label="未接听"></el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      <el-form-item label="已接电话" prop="yesAnswer">
        <el-checkbox-group v-model="formData.yesAnswer">
          <el-checkbox label="未转接"></el-checkbox>
          <el-checkbox label="队列"></el-checkbox>
          <el-checkbox label="失败客户"></el-checkbox>
          <el-checkbox label="成功客户"></el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      <el-form-item label="剔除通话状态" prop="callState">
        <el-checkbox-group v-model="formData.callState">
          <el-checkbox label="AI助手"></el-checkbox>
          <el-checkbox label="正在通话"></el-checkbox>
          <el-checkbox label="用户正忙"></el-checkbox>
          <el-checkbox label="无人接听"></el-checkbox>
          <el-checkbox label="关机"></el-checkbox>
          <el-checkbox label="智能助理"></el-checkbox>
          <el-checkbox label="空号"></el-checkbox>
          <el-checkbox label="停机"></el-checkbox>
          <el-checkbox label="暂停服务"></el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      <el-form-item label="过滤黑名单" prop="notBlack">
        <el-checkbox-group v-model="formData.notBlack">
          <el-checkbox label="过滤黑名单"></el-checkbox>
        </el-checkbox-group>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="onSubmit">提 交</el-button>
      <el-button  @click="handleClose">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getNotCall } from "@/api/taskManagement/taskList.js";
export default {
  name: "recoverDataDialog",
  props: {
    recoverDataDialogShow: {
      type: Boolean,
      default: false,
    },
    questionText: {
      type: String,
      default: "",
    },
    taskId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      loading: false,
      tableData: [], //表格数据
      pagination: {
        pageNum: 1,
        pageSize: 10,
      },
      formData: {
        yesAnswer: [],
        notAnswer: [],
        callState: [],
        notBlack: [],
      },
      voiceTypeList: [],
      rules: {
        questionText: [
          { required: true, message: "内容不能为空", trigger: "blur" },
        ],
      },
      total: 0,
      recoverDataShow: false,
    };
  },

  watch: {
    recoverDataDialogShow: {
      handler(val) {
        if (val) {
          this.recoverDataShow = val;
        }
      },
      immediate: true,
    },
  },
  methods: {
    // 保存
    async onSubmit() {
      const params = {
        ...this.formData,
        notAnswer: this.formData.notAnswer.join(""),
        notBlack: this.formData.notBlack.join(" "),
        taskId: this.taskId,
      };

      const { code, msg } = await getNotCall(params);
      this.handleClose()
      if (code === 200) {
        this.$message.success(msg);
        this.handleClose()
      }
    },

    handleClose() {
      this.recoverDataShow = false;
      this.formData = {
        yesAnswer: [],
        notAnswer: [],
        callState: [],
        notBlack: [],
      };
      this.$emit("onCloseRecoverDataDialog");
    },
  },
};
</script>

<style lang="scss" scoped>
.edit-main {
  ::v-deep .el-textarea__inner {
    height: 150px;
  }
}
</style>
